package idgen

func BuildIdGen(init int, fnNext func(int) int) func() int {
	ch:=make(chan int)

	go func() int {
		next:=init
		for {
			ch <- next
			next=fnNext(next)
		}
	}()

	get:=func() int {
		return <- ch
	}

	return get
}
